<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - ged.info - /usr/include/c++/4.3.2/x86_64-redhat-linux/bits/gthr-default.h</title>
  <link rel="stylesheet" type="text/css" href="../../../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../../../../../index.html">directory</a> - <a href="index.html">usr/include/c++/4.3.2/x86_64-redhat-linux/bits</a> - gthr-default.h</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>ged.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2009-06-09</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">2</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">0.0 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">0</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : /* Threads compatibility routines for libgcc2 and libobjc.  */
<span class="lineNum">       2 </span>                : /* Compile this one with gcc.  */
<span class="lineNum">       3 </span>                : /* Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
<span class="lineNum">       4 </span>                :    Free Software Foundation, Inc.
<span class="lineNum">       5 </span>                : 
<span class="lineNum">       6 </span>                : This file is part of GCC.
<span class="lineNum">       7 </span>                : 
<span class="lineNum">       8 </span>                : GCC is free software; you can redistribute it and/or modify it under
<span class="lineNum">       9 </span>                : the terms of the GNU General Public License as published by the Free
<span class="lineNum">      10 </span>                : Software Foundation; either version 2, or (at your option) any later
<span class="lineNum">      11 </span>                : version.
<span class="lineNum">      12 </span>                : 
<span class="lineNum">      13 </span>                : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
<span class="lineNum">      14 </span>                : WARRANTY; without even the implied warranty of MERCHANTABILITY or
<span class="lineNum">      15 </span>                : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
<span class="lineNum">      16 </span>                : for more details.
<span class="lineNum">      17 </span>                : 
<span class="lineNum">      18 </span>                : You should have received a copy of the GNU General Public License
<span class="lineNum">      19 </span>                : along with GCC; see the file COPYING.  If not, write to the Free
<span class="lineNum">      20 </span>                : Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
<span class="lineNum">      21 </span>                : 02110-1301, USA.  */
<span class="lineNum">      22 </span>                : 
<span class="lineNum">      23 </span>                : /* As a special exception, if you link this library with other files,
<span class="lineNum">      24 </span>                :    some of which are compiled with GCC, to produce an executable,
<span class="lineNum">      25 </span>                :    this library does not by itself cause the resulting executable
<span class="lineNum">      26 </span>                :    to be covered by the GNU General Public License.
<span class="lineNum">      27 </span>                :    This exception does not however invalidate any other reasons why
<span class="lineNum">      28 </span>                :    the executable file might be covered by the GNU General Public License.  */
<span class="lineNum">      29 </span>                : 
<span class="lineNum">      30 </span>                : #ifndef _GLIBCXX_GCC_GTHR_POSIX_H
<span class="lineNum">      31 </span>                : #define _GLIBCXX_GCC_GTHR_POSIX_H
<span class="lineNum">      32 </span>                : 
<span class="lineNum">      33 </span>                : /* POSIX threads specific definitions.
<span class="lineNum">      34 </span>                :    Easy, since the interface is just one-to-one mapping.  */
<span class="lineNum">      35 </span>                : 
<span class="lineNum">      36 </span>                : #define __GTHREADS 1
<span class="lineNum">      37 </span>                : 
<span class="lineNum">      38 </span>                : /* Some implementations of &lt;pthread.h&gt; require this to be defined.  */
<span class="lineNum">      39 </span>                : #if !defined(_REENTRANT) &amp;&amp; defined(__osf__)
<span class="lineNum">      40 </span>                : #define _REENTRANT 1
<span class="lineNum">      41 </span>                : #endif
<span class="lineNum">      42 </span>                : 
<span class="lineNum">      43 </span>                : #include &lt;pthread.h&gt;
<span class="lineNum">      44 </span>                : #include &lt;unistd.h&gt;
<span class="lineNum">      45 </span>                : 
<span class="lineNum">      46 </span>                : typedef pthread_key_t __gthread_key_t;
<span class="lineNum">      47 </span>                : typedef pthread_once_t __gthread_once_t;
<span class="lineNum">      48 </span>                : typedef pthread_mutex_t __gthread_mutex_t;
<span class="lineNum">      49 </span>                : typedef pthread_mutex_t __gthread_recursive_mutex_t;
<span class="lineNum">      50 </span>                : typedef pthread_cond_t __gthread_cond_t;
<span class="lineNum">      51 </span>                : 
<span class="lineNum">      52 </span>                : /* POSIX like conditional variables are supported.  Please look at comments
<span class="lineNum">      53 </span>                :    in gthr.h for details. */
<span class="lineNum">      54 </span>                : #define __GTHREAD_HAS_COND      1       
<span class="lineNum">      55 </span>                : 
<span class="lineNum">      56 </span>                : #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
<span class="lineNum">      57 </span>                : #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
<span class="lineNum">      58 </span>                : #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
<span class="lineNum">      59 </span>                : #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
<span class="lineNum">      60 </span>                : #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
<span class="lineNum">      61 </span>                : #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
<span class="lineNum">      62 </span>                : #else
<span class="lineNum">      63 </span>                : #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
<span class="lineNum">      64 </span>                : #endif
<span class="lineNum">      65 </span>                : #define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER
<span class="lineNum">      66 </span>                : 
<span class="lineNum">      67 </span>                : #if __GXX_WEAK__ &amp;&amp; _GLIBCXX_GTHREAD_USE_WEAK
<span class="lineNum">      68 </span>                : # ifndef __gthrw_pragma
<span class="lineNum">      69 </span>                : #  define __gthrw_pragma(pragma)
<span class="lineNum">      70 </span>                : # endif
<span class="lineNum">      71 </span>                : # define __gthrw2(name,name2,type) \
<span class="lineNum">      72 </span>                :   static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
<span class="lineNum">      73 </span>                :   __gthrw_pragma(weak type)
<span class="lineNum">      74 </span>                : # define __gthrw_(name) __gthrw_ ## name
<span class="lineNum">      75 </span>                : #else
<span class="lineNum">      76 </span>                : # define __gthrw2(name,name2,type)
<span class="lineNum">      77 </span>                : # define __gthrw_(name) name
<span class="lineNum">      78 </span>                : #endif
<span class="lineNum">      79 </span>                : 
<span class="lineNum">      80 </span>                : /* Typically, __gthrw_foo is a weak reference to symbol foo.  */
<span class="lineNum">      81 </span>                : #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
<span class="lineNum">      82 </span>                : 
<span class="lineNum">      83 </span>                : /* On Tru64, /usr/include/pthread.h uses #pragma extern_prefix &quot;__&quot; to
<span class="lineNum">      84 </span>                :    map a subset of the POSIX pthread API to mangled versions of their
<span class="lineNum">      85 </span>                :    names.  */
<span class="lineNum">      86 </span>                : #if defined(__osf__) &amp;&amp; defined(_PTHREAD_USE_MANGLED_NAMES_)
<span class="lineNum">      87 </span>                : #define __gthrw3(name) __gthrw2(__gthrw_ ## name, __ ## name, name)
<span class="lineNum">      88 </span>                : __gthrw3(pthread_once)
<span class="lineNum">      89 </span>                : __gthrw3(pthread_getspecific)
<span class="lineNum">      90 </span>                : __gthrw3(pthread_setspecific)
<span class="lineNum">      91 </span>                : __gthrw3(pthread_create)
<span class="lineNum">      92 </span>                : __gthrw3(pthread_cancel)
<span class="lineNum">      93 </span>                : __gthrw3(pthread_mutex_lock)
<span class="lineNum">      94 </span>                : __gthrw3(pthread_mutex_trylock)
<span class="lineNum">      95 </span>                : __gthrw3(pthread_mutex_unlock)
<span class="lineNum">      96 </span>                : __gthrw3(pthread_mutex_init)
<span class="lineNum">      97 </span>                : __gthrw3(pthread_cond_broadcast)
<span class="lineNum">      98 </span>                : __gthrw3(pthread_cond_wait)
<span class="lineNum">      99 </span>                : #else
<span class="lineNum">     100 </span>                : __gthrw(pthread_once)
<span class="lineNum">     101 </span>                : __gthrw(pthread_getspecific)
<span class="lineNum">     102 </span>                : __gthrw(pthread_setspecific)
<span class="lineNum">     103 </span>                : __gthrw(pthread_create)
<span class="lineNum">     104 </span>                : __gthrw(pthread_cancel)
<span class="lineNum">     105 </span>                : __gthrw(pthread_mutex_lock)
<span class="lineNum">     106 </span>                : __gthrw(pthread_mutex_trylock)
<span class="lineNum">     107 </span>                : __gthrw(pthread_mutex_unlock)
<span class="lineNum">     108 </span>                : __gthrw(pthread_mutex_init)
<span class="lineNum">     109 </span>                : __gthrw(pthread_cond_broadcast)
<span class="lineNum">     110 </span>                : __gthrw(pthread_cond_wait)
<span class="lineNum">     111 </span>                : #endif
<span class="lineNum">     112 </span>                : 
<span class="lineNum">     113 </span>                : __gthrw(pthread_key_create)
<span class="lineNum">     114 </span>                : __gthrw(pthread_key_delete)
<span class="lineNum">     115 </span>                : __gthrw(pthread_mutexattr_init)
<span class="lineNum">     116 </span>                : __gthrw(pthread_mutexattr_settype)
<span class="lineNum">     117 </span>                : __gthrw(pthread_mutexattr_destroy)
<span class="lineNum">     118 </span>                : 
<span class="lineNum">     119 </span>                : 
<span class="lineNum">     120 </span>                : #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
<span class="lineNum">     121 </span>                : /* Objective-C.  */
<span class="lineNum">     122 </span>                : #if defined(__osf__) &amp;&amp; defined(_PTHREAD_USE_MANGLED_NAMES_)
<span class="lineNum">     123 </span>                : __gthrw3(pthread_cond_destroy)
<span class="lineNum">     124 </span>                : __gthrw3(pthread_cond_init)
<span class="lineNum">     125 </span>                : __gthrw3(pthread_cond_signal)
<span class="lineNum">     126 </span>                : __gthrw3(pthread_exit)
<span class="lineNum">     127 </span>                : __gthrw3(pthread_mutex_destroy)
<span class="lineNum">     128 </span>                : __gthrw3(pthread_self)
<span class="lineNum">     129 </span>                : #else
<span class="lineNum">     130 </span>                : __gthrw(pthread_cond_destroy)
<span class="lineNum">     131 </span>                : __gthrw(pthread_cond_init)
<span class="lineNum">     132 </span>                : __gthrw(pthread_cond_signal)
<span class="lineNum">     133 </span>                : __gthrw(pthread_exit)
<span class="lineNum">     134 </span>                : __gthrw(pthread_mutex_destroy)
<span class="lineNum">     135 </span>                : __gthrw(pthread_self)
<span class="lineNum">     136 </span>                : #endif /* __osf__ &amp;&amp; _PTHREAD_USE_MANGLED_NAMES_ */
<span class="lineNum">     137 </span>                : #ifdef _POSIX_PRIORITY_SCHEDULING
<span class="lineNum">     138 </span>                : #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
<span class="lineNum">     139 </span>                : __gthrw(sched_get_priority_max)
<span class="lineNum">     140 </span>                : __gthrw(sched_get_priority_min)
<span class="lineNum">     141 </span>                : #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
<span class="lineNum">     142 </span>                : #endif /* _POSIX_PRIORITY_SCHEDULING */
<span class="lineNum">     143 </span>                : __gthrw(sched_yield)
<span class="lineNum">     144 </span>                : __gthrw(pthread_attr_destroy)
<span class="lineNum">     145 </span>                : __gthrw(pthread_attr_init)
<span class="lineNum">     146 </span>                : __gthrw(pthread_attr_setdetachstate)
<span class="lineNum">     147 </span>                : #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
<span class="lineNum">     148 </span>                : __gthrw(pthread_getschedparam)
<span class="lineNum">     149 </span>                : __gthrw(pthread_setschedparam)
<span class="lineNum">     150 </span>                : #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
<span class="lineNum">     151 </span>                : #endif /* _LIBOBJC || _LIBOBJC_WEAK */
<span class="lineNum">     152 </span>                : 
<span class="lineNum">     153 </span>                : #if __GXX_WEAK__ &amp;&amp; _GLIBCXX_GTHREAD_USE_WEAK
<span class="lineNum">     154 </span>                : 
<span class="lineNum">     155 </span>                : /* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if
<span class="lineNum">     156 </span>                :    -pthreads is not specified.  The functions are dummies and most return an
<span class="lineNum">     157 </span>                :    error value.  However pthread_once returns 0 without invoking the routine
<span class="lineNum">     158 </span>                :    it is passed so we cannot pretend that the interface is active if -pthreads
<span class="lineNum">     159 </span>                :    is not specified.  On Solaris 2.5.1, the interface is not exposed at all so
<span class="lineNum">     160 </span>                :    we need to play the usual game with weak symbols.  On Solaris 10 and up, a
<span class="lineNum">     161 </span>                :    working interface is always exposed.  On FreeBSD 6 and later, libc also
<span class="lineNum">     162 </span>                :    exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
<span class="lineNum">     163 </span>                :    to 9 does.  FreeBSD &gt;= 700014 even provides a pthread_cancel stub in libc,
<span class="lineNum">     164 </span>                :    which means the alternate __gthread_active_p below cannot be used there.  */
<span class="lineNum">     165 </span>                : 
<span class="lineNum">     166 </span>                : #if defined(__FreeBSD__) || (defined(__sun) &amp;&amp; defined(__svr4__))
<span class="lineNum">     167 </span>                : 
<span class="lineNum">     168 </span>                : static volatile int __gthread_active = -1;
<span class="lineNum">     169 </span>                : 
<span class="lineNum">     170 </span>                : static void
<span class="lineNum">     171 </span>                : __gthread_trigger (void)
<span class="lineNum">     172 </span>                : {
<span class="lineNum">     173 </span>                :   __gthread_active = 1;
<span class="lineNum">     174 </span>                : }
<span class="lineNum">     175 </span>                : 
<span class="lineNum">     176 </span>                : static inline int
<span class="lineNum">     177 </span>                : __gthread_active_p (void)
<span class="lineNum">     178 </span>                : {
<span class="lineNum">     179 </span>                :   static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
<span class="lineNum">     180 </span>                :   static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT;
<span class="lineNum">     181 </span>                : 
<span class="lineNum">     182 </span>                :   /* Avoid reading __gthread_active twice on the main code path.  */
<span class="lineNum">     183 </span>                :   int __gthread_active_latest_value = __gthread_active;
<span class="lineNum">     184 </span>                : 
<span class="lineNum">     185 </span>                :   /* This test is not protected to avoid taking a lock on the main code
<span class="lineNum">     186 </span>                :      path so every update of __gthread_active in a threaded program must
<span class="lineNum">     187 </span>                :      be atomic with regard to the result of the test.  */
<span class="lineNum">     188 </span>                :   if (__builtin_expect (__gthread_active_latest_value &lt; 0, 0))
<span class="lineNum">     189 </span>                :     {
<span class="lineNum">     190 </span>                :       if (__gthrw_(pthread_once))
<span class="lineNum">     191 </span>                :         {
<span class="lineNum">     192 </span>                :           /* If this really is a threaded program, then we must ensure that
<span class="lineNum">     193 </span>                :              __gthread_active has been set to 1 before exiting this block.  */
<span class="lineNum">     194 </span>                :           __gthrw_(pthread_mutex_lock) (&amp;__gthread_active_mutex);
<span class="lineNum">     195 </span>                :           __gthrw_(pthread_once) (&amp;__gthread_active_once, __gthread_trigger);
<span class="lineNum">     196 </span>                :           __gthrw_(pthread_mutex_unlock) (&amp;__gthread_active_mutex);
<span class="lineNum">     197 </span>                :         }
<span class="lineNum">     198 </span>                : 
<span class="lineNum">     199 </span>                :       /* Make sure we'll never enter this block again.  */
<span class="lineNum">     200 </span>                :       if (__gthread_active &lt; 0)
<span class="lineNum">     201 </span>                :         __gthread_active = 0;
<span class="lineNum">     202 </span>                : 
<span class="lineNum">     203 </span>                :       __gthread_active_latest_value = __gthread_active;
<span class="lineNum">     204 </span>                :     }
<span class="lineNum">     205 </span>                : 
<span class="lineNum">     206 </span>                :   return __gthread_active_latest_value != 0;
<span class="lineNum">     207 </span>                : }
<span class="lineNum">     208 </span>                : 
<span class="lineNum">     209 </span>                : #else /* neither FreeBSD nor Solaris */
<span class="lineNum">     210 </span>                : 
<span class="lineNum">     211 </span>                : static inline int
<span class="lineNum">     212 </span><span class="lineNoCov">              0 : __gthread_active_p (void)</span>
<span class="lineNum">     213 </span>                : {
<span class="lineNum">     214 </span>                :   static void *const __gthread_active_ptr 
<span class="lineNum">     215 </span>                :     = __extension__ (void *) &amp;__gthrw_(pthread_cancel);
<span class="lineNum">     216 </span><span class="lineNoCov">              0 :   return __gthread_active_ptr != 0;</span>
<span class="lineNum">     217 </span>                : }
<span class="lineNum">     218 </span>                : 
<span class="lineNum">     219 </span>                : #endif /* FreeBSD or Solaris */
<span class="lineNum">     220 </span>                : 
<span class="lineNum">     221 </span>                : #else /* not __GXX_WEAK__ */
<span class="lineNum">     222 </span>                : 
<span class="lineNum">     223 </span>                : /* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread
<span class="lineNum">     224 </span>                :    calls in shared flavors of the HP-UX C library.  Most of the stubs
<span class="lineNum">     225 </span>                :    have no functionality.  The details are described in the &quot;libc cumulative
<span class="lineNum">     226 </span>                :    patch&quot; for each subversion of HP-UX 11.  There are two special interfaces
<span class="lineNum">     227 </span>                :    provided for checking whether an application is linked to a pthread
<span class="lineNum">     228 </span>                :    library or not.  However, these interfaces aren't available in early
<span class="lineNum">     229 </span>                :    libc versions.  We also can't use pthread_once as some libc versions
<span class="lineNum">     230 </span>                :    call the init function.  So, we use pthread_create to check whether it
<span class="lineNum">     231 </span>                :    is possible to create a thread or not.  The stub implementation returns
<span class="lineNum">     232 </span>                :    the error number ENOSYS.  */
<span class="lineNum">     233 </span>                : 
<span class="lineNum">     234 </span>                : #if defined(__hppa__) &amp;&amp; defined(__hpux__)
<span class="lineNum">     235 </span>                : 
<span class="lineNum">     236 </span>                : #include &lt;errno.h&gt;
<span class="lineNum">     237 </span>                : 
<span class="lineNum">     238 </span>                : static volatile int __gthread_active = -1;
<span class="lineNum">     239 </span>                : 
<span class="lineNum">     240 </span>                : static void *
<span class="lineNum">     241 </span>                : __gthread_start (void *arg __attribute__((unused)))
<span class="lineNum">     242 </span>                : {
<span class="lineNum">     243 </span>                :   return NULL;
<span class="lineNum">     244 </span>                : }
<span class="lineNum">     245 </span>                : 
<span class="lineNum">     246 </span>                : static void __gthread_active_init (void) __attribute__((noinline));
<span class="lineNum">     247 </span>                : static void
<span class="lineNum">     248 </span>                : __gthread_active_init (void)
<span class="lineNum">     249 </span>                : {
<span class="lineNum">     250 </span>                :   static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
<span class="lineNum">     251 </span>                :   pthread_t t;
<span class="lineNum">     252 </span>                :   pthread_attr_t a;
<span class="lineNum">     253 </span>                :   int result;
<span class="lineNum">     254 </span>                : 
<span class="lineNum">     255 </span>                :   __gthrw_(pthread_mutex_lock) (&amp;__gthread_active_mutex);
<span class="lineNum">     256 </span>                :   if (__gthread_active &lt; 0)
<span class="lineNum">     257 </span>                :     {
<span class="lineNum">     258 </span>                :       __gthrw_(pthread_attr_init) (&amp;a);
<span class="lineNum">     259 </span>                :       __gthrw_(pthread_attr_setdetachstate) (&amp;a, PTHREAD_CREATE_DETACHED);
<span class="lineNum">     260 </span>                :       result = __gthrw_(pthread_create) (&amp;t, &amp;a, __gthread_start, NULL);
<span class="lineNum">     261 </span>                :       if (result != ENOSYS)
<span class="lineNum">     262 </span>                :         __gthread_active = 1;
<span class="lineNum">     263 </span>                :       else
<span class="lineNum">     264 </span>                :         __gthread_active = 0;
<span class="lineNum">     265 </span>                :       __gthrw_(pthread_attr_destroy) (&amp;a);
<span class="lineNum">     266 </span>                :     }
<span class="lineNum">     267 </span>                :   __gthrw_(pthread_mutex_unlock) (&amp;__gthread_active_mutex);
<span class="lineNum">     268 </span>                : }
<span class="lineNum">     269 </span>                : 
<span class="lineNum">     270 </span>                : static inline int
<span class="lineNum">     271 </span>                : __gthread_active_p (void)
<span class="lineNum">     272 </span>                : {
<span class="lineNum">     273 </span>                :   /* Avoid reading __gthread_active twice on the main code path.  */
<span class="lineNum">     274 </span>                :   int __gthread_active_latest_value = __gthread_active;
<span class="lineNum">     275 </span>                : 
<span class="lineNum">     276 </span>                :   /* This test is not protected to avoid taking a lock on the main code
<span class="lineNum">     277 </span>                :      path so every update of __gthread_active in a threaded program must
<span class="lineNum">     278 </span>                :      be atomic with regard to the result of the test.  */
<span class="lineNum">     279 </span>                :   if (__builtin_expect (__gthread_active_latest_value &lt; 0, 0))
<span class="lineNum">     280 </span>                :     {
<span class="lineNum">     281 </span>                :       __gthread_active_init ();
<span class="lineNum">     282 </span>                :       __gthread_active_latest_value = __gthread_active;
<span class="lineNum">     283 </span>                :     }
<span class="lineNum">     284 </span>                : 
<span class="lineNum">     285 </span>                :   return __gthread_active_latest_value != 0;
<span class="lineNum">     286 </span>                : }
<span class="lineNum">     287 </span>                : 
<span class="lineNum">     288 </span>                : #else /* not hppa-hpux */
<span class="lineNum">     289 </span>                : 
<span class="lineNum">     290 </span>                : static inline int
<span class="lineNum">     291 </span>                : __gthread_active_p (void)
<span class="lineNum">     292 </span>                : {
<span class="lineNum">     293 </span>                :   return 1;
<span class="lineNum">     294 </span>                : }
<span class="lineNum">     295 </span>                : 
<span class="lineNum">     296 </span>                : #endif /* hppa-hpux */
<span class="lineNum">     297 </span>                : 
<span class="lineNum">     298 </span>                : #endif /* __GXX_WEAK__ */
<span class="lineNum">     299 </span>                : 
<span class="lineNum">     300 </span>                : #ifdef _LIBOBJC
<span class="lineNum">     301 </span>                : 
<span class="lineNum">     302 </span>                : /* This is the config.h file in libobjc/ */
<span class="lineNum">     303 </span>                : #include &lt;config.h&gt;
<span class="lineNum">     304 </span>                : 
<span class="lineNum">     305 </span>                : #ifdef HAVE_SCHED_H
<span class="lineNum">     306 </span>                : # include &lt;sched.h&gt;
<span class="lineNum">     307 </span>                : #endif
<span class="lineNum">     308 </span>                : 
<span class="lineNum">     309 </span>                : /* Key structure for maintaining thread specific storage */
<span class="lineNum">     310 </span>                : static pthread_key_t _objc_thread_storage;
<span class="lineNum">     311 </span>                : static pthread_attr_t _objc_thread_attribs;
<span class="lineNum">     312 </span>                : 
<span class="lineNum">     313 </span>                : /* Thread local storage for a single thread */
<span class="lineNum">     314 </span>                : static void *thread_local_storage = NULL;
<span class="lineNum">     315 </span>                : 
<span class="lineNum">     316 </span>                : /* Backend initialization functions */
<span class="lineNum">     317 </span>                : 
<span class="lineNum">     318 </span>                : /* Initialize the threads subsystem.  */
<span class="lineNum">     319 </span>                : static inline int
<span class="lineNum">     320 </span>                : __gthread_objc_init_thread_system (void)
<span class="lineNum">     321 </span>                : {
<span class="lineNum">     322 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     323 </span>                :     {
<span class="lineNum">     324 </span>                :       /* Initialize the thread storage key.  */
<span class="lineNum">     325 </span>                :       if (__gthrw_(pthread_key_create) (&amp;_objc_thread_storage, NULL) == 0)
<span class="lineNum">     326 </span>                :         {
<span class="lineNum">     327 </span>                :           /* The normal default detach state for threads is
<span class="lineNum">     328 </span>                :            * PTHREAD_CREATE_JOINABLE which causes threads to not die
<span class="lineNum">     329 </span>                :            * when you think they should.  */
<span class="lineNum">     330 </span>                :           if (__gthrw_(pthread_attr_init) (&amp;_objc_thread_attribs) == 0
<span class="lineNum">     331 </span>                :               &amp;&amp; __gthrw_(pthread_attr_setdetachstate) (&amp;_objc_thread_attribs,
<span class="lineNum">     332 </span>                :                                               PTHREAD_CREATE_DETACHED) == 0)
<span class="lineNum">     333 </span>                :             return 0;
<span class="lineNum">     334 </span>                :         }
<span class="lineNum">     335 </span>                :     }
<span class="lineNum">     336 </span>                : 
<span class="lineNum">     337 </span>                :   return -1;
<span class="lineNum">     338 </span>                : }
<span class="lineNum">     339 </span>                : 
<span class="lineNum">     340 </span>                : /* Close the threads subsystem.  */
<span class="lineNum">     341 </span>                : static inline int
<span class="lineNum">     342 </span>                : __gthread_objc_close_thread_system (void)
<span class="lineNum">     343 </span>                : {
<span class="lineNum">     344 </span>                :   if (__gthread_active_p ()
<span class="lineNum">     345 </span>                :       &amp;&amp; __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0
<span class="lineNum">     346 </span>                :       &amp;&amp; __gthrw_(pthread_attr_destroy) (&amp;_objc_thread_attribs) == 0)
<span class="lineNum">     347 </span>                :     return 0;
<span class="lineNum">     348 </span>                : 
<span class="lineNum">     349 </span>                :   return -1;
<span class="lineNum">     350 </span>                : }
<span class="lineNum">     351 </span>                : 
<span class="lineNum">     352 </span>                : /* Backend thread functions */
<span class="lineNum">     353 </span>                : 
<span class="lineNum">     354 </span>                : /* Create a new thread of execution.  */
<span class="lineNum">     355 </span>                : static inline objc_thread_t
<span class="lineNum">     356 </span>                : __gthread_objc_thread_detach (void (*func)(void *), void *arg)
<span class="lineNum">     357 </span>                : {
<span class="lineNum">     358 </span>                :   objc_thread_t thread_id;
<span class="lineNum">     359 </span>                :   pthread_t new_thread_handle;
<span class="lineNum">     360 </span>                : 
<span class="lineNum">     361 </span>                :   if (!__gthread_active_p ())
<span class="lineNum">     362 </span>                :     return NULL;
<span class="lineNum">     363 </span>                : 
<span class="lineNum">     364 </span>                :   if (!(__gthrw_(pthread_create) (&amp;new_thread_handle, NULL, (void *) func, arg)))
<span class="lineNum">     365 </span>                :     thread_id = (objc_thread_t) new_thread_handle;
<span class="lineNum">     366 </span>                :   else
<span class="lineNum">     367 </span>                :     thread_id = NULL;
<span class="lineNum">     368 </span>                : 
<span class="lineNum">     369 </span>                :   return thread_id;
<span class="lineNum">     370 </span>                : }
<span class="lineNum">     371 </span>                : 
<span class="lineNum">     372 </span>                : /* Set the current thread's priority.  */
<span class="lineNum">     373 </span>                : static inline int
<span class="lineNum">     374 </span>                : __gthread_objc_thread_set_priority (int priority)
<span class="lineNum">     375 </span>                : {
<span class="lineNum">     376 </span>                :   if (!__gthread_active_p ())
<span class="lineNum">     377 </span>                :     return -1;
<span class="lineNum">     378 </span>                :   else
<span class="lineNum">     379 </span>                :     {
<span class="lineNum">     380 </span>                : #ifdef _POSIX_PRIORITY_SCHEDULING
<span class="lineNum">     381 </span>                : #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
<span class="lineNum">     382 </span>                :       pthread_t thread_id = __gthrw_(pthread_self) ();
<span class="lineNum">     383 </span>                :       int policy;
<span class="lineNum">     384 </span>                :       struct sched_param params;
<span class="lineNum">     385 </span>                :       int priority_min, priority_max;
<span class="lineNum">     386 </span>                : 
<span class="lineNum">     387 </span>                :       if (__gthrw_(pthread_getschedparam) (thread_id, &amp;policy, &amp;params) == 0)
<span class="lineNum">     388 </span>                :         {
<span class="lineNum">     389 </span>                :           if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1)
<span class="lineNum">     390 </span>                :             return -1;
<span class="lineNum">     391 </span>                : 
<span class="lineNum">     392 </span>                :           if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1)
<span class="lineNum">     393 </span>                :             return -1;
<span class="lineNum">     394 </span>                : 
<span class="lineNum">     395 </span>                :           if (priority &gt; priority_max)
<span class="lineNum">     396 </span>                :             priority = priority_max;
<span class="lineNum">     397 </span>                :           else if (priority &lt; priority_min)
<span class="lineNum">     398 </span>                :             priority = priority_min;
<span class="lineNum">     399 </span>                :           params.sched_priority = priority;
<span class="lineNum">     400 </span>                : 
<span class="lineNum">     401 </span>                :           /*
<span class="lineNum">     402 </span>                :            * The solaris 7 and several other man pages incorrectly state that
<span class="lineNum">     403 </span>                :            * this should be a pointer to policy but pthread.h is universally
<span class="lineNum">     404 </span>                :            * at odds with this.
<span class="lineNum">     405 </span>                :            */
<span class="lineNum">     406 </span>                :           if (__gthrw_(pthread_setschedparam) (thread_id, policy, &amp;params) == 0)
<span class="lineNum">     407 </span>                :             return 0;
<span class="lineNum">     408 </span>                :         }
<span class="lineNum">     409 </span>                : #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
<span class="lineNum">     410 </span>                : #endif /* _POSIX_PRIORITY_SCHEDULING */
<span class="lineNum">     411 </span>                :       return -1;
<span class="lineNum">     412 </span>                :     }
<span class="lineNum">     413 </span>                : }
<span class="lineNum">     414 </span>                : 
<span class="lineNum">     415 </span>                : /* Return the current thread's priority.  */
<span class="lineNum">     416 </span>                : static inline int
<span class="lineNum">     417 </span>                : __gthread_objc_thread_get_priority (void)
<span class="lineNum">     418 </span>                : {
<span class="lineNum">     419 </span>                : #ifdef _POSIX_PRIORITY_SCHEDULING
<span class="lineNum">     420 </span>                : #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
<span class="lineNum">     421 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     422 </span>                :     {
<span class="lineNum">     423 </span>                :       int policy;
<span class="lineNum">     424 </span>                :       struct sched_param params;
<span class="lineNum">     425 </span>                : 
<span class="lineNum">     426 </span>                :       if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &amp;policy, &amp;params) == 0)
<span class="lineNum">     427 </span>                :         return params.sched_priority;
<span class="lineNum">     428 </span>                :       else
<span class="lineNum">     429 </span>                :         return -1;
<span class="lineNum">     430 </span>                :     }
<span class="lineNum">     431 </span>                :   else
<span class="lineNum">     432 </span>                : #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
<span class="lineNum">     433 </span>                : #endif /* _POSIX_PRIORITY_SCHEDULING */
<span class="lineNum">     434 </span>                :     return OBJC_THREAD_INTERACTIVE_PRIORITY;
<span class="lineNum">     435 </span>                : }
<span class="lineNum">     436 </span>                : 
<span class="lineNum">     437 </span>                : /* Yield our process time to another thread.  */
<span class="lineNum">     438 </span>                : static inline void
<span class="lineNum">     439 </span>                : __gthread_objc_thread_yield (void)
<span class="lineNum">     440 </span>                : {
<span class="lineNum">     441 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     442 </span>                :     __gthrw_(sched_yield) ();
<span class="lineNum">     443 </span>                : }
<span class="lineNum">     444 </span>                : 
<span class="lineNum">     445 </span>                : /* Terminate the current thread.  */
<span class="lineNum">     446 </span>                : static inline int
<span class="lineNum">     447 </span>                : __gthread_objc_thread_exit (void)
<span class="lineNum">     448 </span>                : {
<span class="lineNum">     449 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     450 </span>                :     /* exit the thread */
<span class="lineNum">     451 </span>                :     __gthrw_(pthread_exit) (&amp;__objc_thread_exit_status);
<span class="lineNum">     452 </span>                : 
<span class="lineNum">     453 </span>                :   /* Failed if we reached here */
<span class="lineNum">     454 </span>                :   return -1;
<span class="lineNum">     455 </span>                : }
<span class="lineNum">     456 </span>                : 
<span class="lineNum">     457 </span>                : /* Returns an integer value which uniquely describes a thread.  */
<span class="lineNum">     458 </span>                : static inline objc_thread_t
<span class="lineNum">     459 </span>                : __gthread_objc_thread_id (void)
<span class="lineNum">     460 </span>                : {
<span class="lineNum">     461 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     462 </span>                :     return (objc_thread_t) __gthrw_(pthread_self) ();
<span class="lineNum">     463 </span>                :   else
<span class="lineNum">     464 </span>                :     return (objc_thread_t) 1;
<span class="lineNum">     465 </span>                : }
<span class="lineNum">     466 </span>                : 
<span class="lineNum">     467 </span>                : /* Sets the thread's local storage pointer.  */
<span class="lineNum">     468 </span>                : static inline int
<span class="lineNum">     469 </span>                : __gthread_objc_thread_set_data (void *value)
<span class="lineNum">     470 </span>                : {
<span class="lineNum">     471 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     472 </span>                :     return __gthrw_(pthread_setspecific) (_objc_thread_storage, value);
<span class="lineNum">     473 </span>                :   else
<span class="lineNum">     474 </span>                :     {
<span class="lineNum">     475 </span>                :       thread_local_storage = value;
<span class="lineNum">     476 </span>                :       return 0;
<span class="lineNum">     477 </span>                :     }
<span class="lineNum">     478 </span>                : }
<span class="lineNum">     479 </span>                : 
<span class="lineNum">     480 </span>                : /* Returns the thread's local storage pointer.  */
<span class="lineNum">     481 </span>                : static inline void *
<span class="lineNum">     482 </span>                : __gthread_objc_thread_get_data (void)
<span class="lineNum">     483 </span>                : {
<span class="lineNum">     484 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     485 </span>                :     return __gthrw_(pthread_getspecific) (_objc_thread_storage);
<span class="lineNum">     486 </span>                :   else
<span class="lineNum">     487 </span>                :     return thread_local_storage;
<span class="lineNum">     488 </span>                : }
<span class="lineNum">     489 </span>                : 
<span class="lineNum">     490 </span>                : /* Backend mutex functions */
<span class="lineNum">     491 </span>                : 
<span class="lineNum">     492 </span>                : /* Allocate a mutex.  */
<span class="lineNum">     493 </span>                : static inline int
<span class="lineNum">     494 </span>                : __gthread_objc_mutex_allocate (objc_mutex_t mutex)
<span class="lineNum">     495 </span>                : {
<span class="lineNum">     496 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     497 </span>                :     {
<span class="lineNum">     498 </span>                :       mutex-&gt;backend = objc_malloc (sizeof (pthread_mutex_t));
<span class="lineNum">     499 </span>                : 
<span class="lineNum">     500 </span>                :       if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex-&gt;backend, NULL))
<span class="lineNum">     501 </span>                :         {
<span class="lineNum">     502 </span>                :           objc_free (mutex-&gt;backend);
<span class="lineNum">     503 </span>                :           mutex-&gt;backend = NULL;
<span class="lineNum">     504 </span>                :           return -1;
<span class="lineNum">     505 </span>                :         }
<span class="lineNum">     506 </span>                :     }
<span class="lineNum">     507 </span>                : 
<span class="lineNum">     508 </span>                :   return 0;
<span class="lineNum">     509 </span>                : }
<span class="lineNum">     510 </span>                : 
<span class="lineNum">     511 </span>                : /* Deallocate a mutex.  */
<span class="lineNum">     512 </span>                : static inline int
<span class="lineNum">     513 </span>                : __gthread_objc_mutex_deallocate (objc_mutex_t mutex)
<span class="lineNum">     514 </span>                : {
<span class="lineNum">     515 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     516 </span>                :     {
<span class="lineNum">     517 </span>                :       int count;
<span class="lineNum">     518 </span>                : 
<span class="lineNum">     519 </span>                :       /*
<span class="lineNum">     520 </span>                :        * Posix Threads specifically require that the thread be unlocked
<span class="lineNum">     521 </span>                :        * for __gthrw_(pthread_mutex_destroy) to work.
<span class="lineNum">     522 </span>                :        */
<span class="lineNum">     523 </span>                : 
<span class="lineNum">     524 </span>                :       do
<span class="lineNum">     525 </span>                :         {
<span class="lineNum">     526 </span>                :           count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex-&gt;backend);
<span class="lineNum">     527 </span>                :           if (count &lt; 0)
<span class="lineNum">     528 </span>                :             return -1;
<span class="lineNum">     529 </span>                :         }
<span class="lineNum">     530 </span>                :       while (count);
<span class="lineNum">     531 </span>                : 
<span class="lineNum">     532 </span>                :       if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex-&gt;backend))
<span class="lineNum">     533 </span>                :         return -1;
<span class="lineNum">     534 </span>                : 
<span class="lineNum">     535 </span>                :       objc_free (mutex-&gt;backend);
<span class="lineNum">     536 </span>                :       mutex-&gt;backend = NULL;
<span class="lineNum">     537 </span>                :     }
<span class="lineNum">     538 </span>                :   return 0;
<span class="lineNum">     539 </span>                : }
<span class="lineNum">     540 </span>                : 
<span class="lineNum">     541 </span>                : /* Grab a lock on a mutex.  */
<span class="lineNum">     542 </span>                : static inline int
<span class="lineNum">     543 </span>                : __gthread_objc_mutex_lock (objc_mutex_t mutex)
<span class="lineNum">     544 </span>                : {
<span class="lineNum">     545 </span>                :   if (__gthread_active_p ()
<span class="lineNum">     546 </span>                :       &amp;&amp; __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex-&gt;backend) != 0)
<span class="lineNum">     547 </span>                :     {
<span class="lineNum">     548 </span>                :       return -1;
<span class="lineNum">     549 </span>                :     }
<span class="lineNum">     550 </span>                : 
<span class="lineNum">     551 </span>                :   return 0;
<span class="lineNum">     552 </span>                : }
<span class="lineNum">     553 </span>                : 
<span class="lineNum">     554 </span>                : /* Try to grab a lock on a mutex.  */
<span class="lineNum">     555 </span>                : static inline int
<span class="lineNum">     556 </span>                : __gthread_objc_mutex_trylock (objc_mutex_t mutex)
<span class="lineNum">     557 </span>                : {
<span class="lineNum">     558 </span>                :   if (__gthread_active_p ()
<span class="lineNum">     559 </span>                :       &amp;&amp; __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex-&gt;backend) != 0)
<span class="lineNum">     560 </span>                :     {
<span class="lineNum">     561 </span>                :       return -1;
<span class="lineNum">     562 </span>                :     }
<span class="lineNum">     563 </span>                : 
<span class="lineNum">     564 </span>                :   return 0;
<span class="lineNum">     565 </span>                : }
<span class="lineNum">     566 </span>                : 
<span class="lineNum">     567 </span>                : /* Unlock the mutex */
<span class="lineNum">     568 </span>                : static inline int
<span class="lineNum">     569 </span>                : __gthread_objc_mutex_unlock (objc_mutex_t mutex)
<span class="lineNum">     570 </span>                : {
<span class="lineNum">     571 </span>                :   if (__gthread_active_p ()
<span class="lineNum">     572 </span>                :       &amp;&amp; __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex-&gt;backend) != 0)
<span class="lineNum">     573 </span>                :     {
<span class="lineNum">     574 </span>                :       return -1;
<span class="lineNum">     575 </span>                :     }
<span class="lineNum">     576 </span>                : 
<span class="lineNum">     577 </span>                :   return 0;
<span class="lineNum">     578 </span>                : }
<span class="lineNum">     579 </span>                : 
<span class="lineNum">     580 </span>                : /* Backend condition mutex functions */
<span class="lineNum">     581 </span>                : 
<span class="lineNum">     582 </span>                : /* Allocate a condition.  */
<span class="lineNum">     583 </span>                : static inline int
<span class="lineNum">     584 </span>                : __gthread_objc_condition_allocate (objc_condition_t condition)
<span class="lineNum">     585 </span>                : {
<span class="lineNum">     586 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     587 </span>                :     {
<span class="lineNum">     588 </span>                :       condition-&gt;backend = objc_malloc (sizeof (pthread_cond_t));
<span class="lineNum">     589 </span>                : 
<span class="lineNum">     590 </span>                :       if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition-&gt;backend, NULL))
<span class="lineNum">     591 </span>                :         {
<span class="lineNum">     592 </span>                :           objc_free (condition-&gt;backend);
<span class="lineNum">     593 </span>                :           condition-&gt;backend = NULL;
<span class="lineNum">     594 </span>                :           return -1;
<span class="lineNum">     595 </span>                :         }
<span class="lineNum">     596 </span>                :     }
<span class="lineNum">     597 </span>                : 
<span class="lineNum">     598 </span>                :   return 0;
<span class="lineNum">     599 </span>                : }
<span class="lineNum">     600 </span>                : 
<span class="lineNum">     601 </span>                : /* Deallocate a condition.  */
<span class="lineNum">     602 </span>                : static inline int
<span class="lineNum">     603 </span>                : __gthread_objc_condition_deallocate (objc_condition_t condition)
<span class="lineNum">     604 </span>                : {
<span class="lineNum">     605 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     606 </span>                :     {
<span class="lineNum">     607 </span>                :       if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition-&gt;backend))
<span class="lineNum">     608 </span>                :         return -1;
<span class="lineNum">     609 </span>                : 
<span class="lineNum">     610 </span>                :       objc_free (condition-&gt;backend);
<span class="lineNum">     611 </span>                :       condition-&gt;backend = NULL;
<span class="lineNum">     612 </span>                :     }
<span class="lineNum">     613 </span>                :   return 0;
<span class="lineNum">     614 </span>                : }
<span class="lineNum">     615 </span>                : 
<span class="lineNum">     616 </span>                : /* Wait on the condition */
<span class="lineNum">     617 </span>                : static inline int
<span class="lineNum">     618 </span>                : __gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
<span class="lineNum">     619 </span>                : {
<span class="lineNum">     620 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     621 </span>                :     return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition-&gt;backend,
<span class="lineNum">     622 </span>                :                               (pthread_mutex_t *) mutex-&gt;backend);
<span class="lineNum">     623 </span>                :   else
<span class="lineNum">     624 </span>                :     return 0;
<span class="lineNum">     625 </span>                : }
<span class="lineNum">     626 </span>                : 
<span class="lineNum">     627 </span>                : /* Wake up all threads waiting on this condition.  */
<span class="lineNum">     628 </span>                : static inline int
<span class="lineNum">     629 </span>                : __gthread_objc_condition_broadcast (objc_condition_t condition)
<span class="lineNum">     630 </span>                : {
<span class="lineNum">     631 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     632 </span>                :     return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition-&gt;backend);
<span class="lineNum">     633 </span>                :   else
<span class="lineNum">     634 </span>                :     return 0;
<span class="lineNum">     635 </span>                : }
<span class="lineNum">     636 </span>                : 
<span class="lineNum">     637 </span>                : /* Wake up one thread waiting on this condition.  */
<span class="lineNum">     638 </span>                : static inline int
<span class="lineNum">     639 </span>                : __gthread_objc_condition_signal (objc_condition_t condition)
<span class="lineNum">     640 </span>                : {
<span class="lineNum">     641 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     642 </span>                :     return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition-&gt;backend);
<span class="lineNum">     643 </span>                :   else
<span class="lineNum">     644 </span>                :     return 0;
<span class="lineNum">     645 </span>                : }
<span class="lineNum">     646 </span>                : 
<span class="lineNum">     647 </span>                : #else /* _LIBOBJC */
<span class="lineNum">     648 </span>                : 
<span class="lineNum">     649 </span>                : static inline int
<span class="lineNum">     650 </span>                : __gthread_once (__gthread_once_t *once, void (*func) (void))
<span class="lineNum">     651 </span>                : {
<span class="lineNum">     652 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     653 </span>                :     return __gthrw_(pthread_once) (once, func);
<span class="lineNum">     654 </span>                :   else
<span class="lineNum">     655 </span>                :     return -1;
<span class="lineNum">     656 </span>                : }
<span class="lineNum">     657 </span>                : 
<span class="lineNum">     658 </span>                : static inline int
<span class="lineNum">     659 </span>                : __gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
<span class="lineNum">     660 </span>                : {
<span class="lineNum">     661 </span>                :   return __gthrw_(pthread_key_create) (key, dtor);
<span class="lineNum">     662 </span>                : }
<span class="lineNum">     663 </span>                : 
<span class="lineNum">     664 </span>                : static inline int
<span class="lineNum">     665 </span>                : __gthread_key_delete (__gthread_key_t key)
<span class="lineNum">     666 </span>                : {
<span class="lineNum">     667 </span>                :   return __gthrw_(pthread_key_delete) (key);
<span class="lineNum">     668 </span>                : }
<span class="lineNum">     669 </span>                : 
<span class="lineNum">     670 </span>                : static inline void *
<span class="lineNum">     671 </span>                : __gthread_getspecific (__gthread_key_t key)
<span class="lineNum">     672 </span>                : {
<span class="lineNum">     673 </span>                :   return __gthrw_(pthread_getspecific) (key);
<span class="lineNum">     674 </span>                : }
<span class="lineNum">     675 </span>                : 
<span class="lineNum">     676 </span>                : static inline int
<span class="lineNum">     677 </span>                : __gthread_setspecific (__gthread_key_t key, const void *ptr)
<span class="lineNum">     678 </span>                : {
<span class="lineNum">     679 </span>                :   return __gthrw_(pthread_setspecific) (key, ptr);
<span class="lineNum">     680 </span>                : }
<span class="lineNum">     681 </span>                : 
<span class="lineNum">     682 </span>                : static inline int
<span class="lineNum">     683 </span>                : __gthread_mutex_lock (__gthread_mutex_t *mutex)
<span class="lineNum">     684 </span>                : {
<span class="lineNum">     685 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     686 </span>                :     return __gthrw_(pthread_mutex_lock) (mutex);
<span class="lineNum">     687 </span>                :   else
<span class="lineNum">     688 </span>                :     return 0;
<span class="lineNum">     689 </span>                : }
<span class="lineNum">     690 </span>                : 
<span class="lineNum">     691 </span>                : static inline int
<span class="lineNum">     692 </span>                : __gthread_mutex_trylock (__gthread_mutex_t *mutex)
<span class="lineNum">     693 </span>                : {
<span class="lineNum">     694 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     695 </span>                :     return __gthrw_(pthread_mutex_trylock) (mutex);
<span class="lineNum">     696 </span>                :   else
<span class="lineNum">     697 </span>                :     return 0;
<span class="lineNum">     698 </span>                : }
<span class="lineNum">     699 </span>                : 
<span class="lineNum">     700 </span>                : static inline int
<span class="lineNum">     701 </span>                : __gthread_mutex_unlock (__gthread_mutex_t *mutex)
<span class="lineNum">     702 </span>                : {
<span class="lineNum">     703 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     704 </span>                :     return __gthrw_(pthread_mutex_unlock) (mutex);
<span class="lineNum">     705 </span>                :   else
<span class="lineNum">     706 </span>                :     return 0;
<span class="lineNum">     707 </span>                : }
<span class="lineNum">     708 </span>                : 
<span class="lineNum">     709 </span>                : #ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
<span class="lineNum">     710 </span>                : static inline int
<span class="lineNum">     711 </span>                : __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
<span class="lineNum">     712 </span>                : {
<span class="lineNum">     713 </span>                :   if (__gthread_active_p ())
<span class="lineNum">     714 </span>                :     {
<span class="lineNum">     715 </span>                :       pthread_mutexattr_t attr;
<span class="lineNum">     716 </span>                :       int r;
<span class="lineNum">     717 </span>                : 
<span class="lineNum">     718 </span>                :       r = __gthrw_(pthread_mutexattr_init) (&amp;attr);
<span class="lineNum">     719 </span>                :       if (!r)
<span class="lineNum">     720 </span>                :         r = __gthrw_(pthread_mutexattr_settype) (&amp;attr, PTHREAD_MUTEX_RECURSIVE);
<span class="lineNum">     721 </span>                :       if (!r)
<span class="lineNum">     722 </span>                :         r = __gthrw_(pthread_mutex_init) (mutex, &amp;attr);
<span class="lineNum">     723 </span>                :       if (!r)
<span class="lineNum">     724 </span>                :         r = __gthrw_(pthread_mutexattr_destroy) (&amp;attr);
<span class="lineNum">     725 </span>                :       return r;
<span class="lineNum">     726 </span>                :     }
<span class="lineNum">     727 </span>                :   return 0;
<span class="lineNum">     728 </span>                : }
<span class="lineNum">     729 </span>                : #endif
<span class="lineNum">     730 </span>                : 
<span class="lineNum">     731 </span>                : static inline int
<span class="lineNum">     732 </span>                : __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
<span class="lineNum">     733 </span>                : {
<span class="lineNum">     734 </span>                :   return __gthread_mutex_lock (mutex);
<span class="lineNum">     735 </span>                : }
<span class="lineNum">     736 </span>                : 
<span class="lineNum">     737 </span>                : static inline int
<span class="lineNum">     738 </span>                : __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
<span class="lineNum">     739 </span>                : {
<span class="lineNum">     740 </span>                :   return __gthread_mutex_trylock (mutex);
<span class="lineNum">     741 </span>                : }
<span class="lineNum">     742 </span>                : 
<span class="lineNum">     743 </span>                : static inline int
<span class="lineNum">     744 </span>                : __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
<span class="lineNum">     745 </span>                : {
<span class="lineNum">     746 </span>                :   return __gthread_mutex_unlock (mutex);
<span class="lineNum">     747 </span>                : }
<span class="lineNum">     748 </span>                : 
<span class="lineNum">     749 </span>                : static inline int
<span class="lineNum">     750 </span>                : __gthread_cond_broadcast (__gthread_cond_t *cond)
<span class="lineNum">     751 </span>                : {
<span class="lineNum">     752 </span>                :   return __gthrw_(pthread_cond_broadcast) (cond);
<span class="lineNum">     753 </span>                : }
<span class="lineNum">     754 </span>                : 
<span class="lineNum">     755 </span>                : static inline int
<span class="lineNum">     756 </span>                : __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex)
<span class="lineNum">     757 </span>                : {
<span class="lineNum">     758 </span>                :   return __gthrw_(pthread_cond_wait) (cond, mutex);
<span class="lineNum">     759 </span>                : }
<span class="lineNum">     760 </span>                : 
<span class="lineNum">     761 </span>                : static inline int
<span class="lineNum">     762 </span>                : __gthread_cond_wait_recursive (__gthread_cond_t *cond,
<span class="lineNum">     763 </span>                :                                __gthread_recursive_mutex_t *mutex)
<span class="lineNum">     764 </span>                : {
<span class="lineNum">     765 </span>                :   return __gthread_cond_wait (cond, mutex);
<span class="lineNum">     766 </span>                : }
<span class="lineNum">     767 </span>                : 
<span class="lineNum">     768 </span>                : #endif /* _LIBOBJC */
<span class="lineNum">     769 </span>                : 
<span class="lineNum">     770 </span>                : #endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
